package com.chapter11.classic_case;


public class BigCase {
    public static void main(String[] args) {

        //枚举常量调用方法
        Sex.female.program();


    }
}

interface Program{
    void program();
}

enum Sex implements Program{

    man("男"),female("女");
    private String sex;

    Sex(String sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "Sex{" +
                "sex='" + sex + '\'' +
                '}';
    }

    //匿名内部类实现接口方法重写.甚至无法访问枚举类的属性
    Program program = new Program() {
        @Override
        public void program() {
            if (sex == "man"){
                System.out.println("be suit to program");
            }
            System.out.println("not be suit to program");
        }

    };


    //这里仍然需要在枚举类中显示再次重写方法，只需把匿名内部类的对象传进来即可
    @Override
    public void program() {
        System.out.println(program);
    }
}